#pragma once
#include"hash_table.hpp"

template<class K, class Hash = hashfunc<K>>
class my_unordered_set {
public:
	struct setKofT {
		const K& operator()(const K& key)
		{
			return key;
		}
	};
	typedef typename hash_table<K, K, Hash, setKofT>::const_iterator iterator;
	typedef typename hash_table<K, K, Hash, setKofT>::const_iterator const_iterator;


	pair<iterator, bool> insert(const K& data)
	{
		return _hash.insert(data);
	}

	bool erase(const K& key)
	{
		return _hash.erase(key);
	}

	iterator begin()
	{
		return _hash.begin();
	}

	iterator end()
	{
		return _hash.end();
	}

	const_iterator begin()const
	{
		return _hash.begin();
	}

	const_iterator end()const
	{
		return _hash.end();
	}

private:
	hash_table<K, K, Hash, setKofT> _hash;
};

void testnuordered_set()
{
	my_unordered_set<string> us;
	us.insert("hello");
	us.insert("left");
	us.insert("");
	us.insert("yes");

	auto it = us.begin();
	while (it != us.end())
	{
		cout << *it << " ";
		++it;
	}
	cout << endl;

}